﻿namespace X2OPC.Core.DA
{
    using System;
    using System.Runtime.InteropServices;

    [ComImport, ComVisible(true), Guid("39c13a50-011e-11d0-9675-0020afd8adb3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IOPCGroupStateMgt
    {
        /// <summary>
        /// 取得OPCGroup的状态即设定信息 
        /// </summary>
        /// <param name="pUpdateRate">更新率</param>
        /// <param name="pActive">激活状态</param>
        /// <param name="ppName">组名称</param>
        /// <param name="pTimeBias">时区偏移</param>
        /// <param name="pPercentDeadband">百分比死区</param>
        /// <param name="pLCID">当前语言标识</param>
        /// <param name="phClientGroup">客户程序提供给组对象的句柄</param>
        /// <param name="phServerGroup">客户程序提供给组对象的句柄</param>
        /// <returns></returns>
        [PreserveSig]
        int GetState(
            [Out]										out	int pUpdateRate,
            [Out, MarshalAs(UnmanagedType.Bool)]		out	bool pActive,
            [Out, MarshalAs(UnmanagedType.LPWStr)]		out	string ppName,
            [Out]										out	int pTimeBias,
            [Out]										out	float pPercentDeadband,
            [Out]										out	int pLCID,
            [Out]										out	int phClientGroup,
            [Out]										out	int phServerGroup);

        /// <summary>
        /// 设定OPCGroup 的状态信息
        /// </summary>
        /// <param name="pRequestedUpdateRate"></param>
        /// <param name="pRevisedUpdateRate"></param>
        /// <param name="pActive"></param>
        /// <param name="pTimeBias"></param>
        /// <param name="pPercentDeadband"></param>
        /// <param name="pLCID"></param>
        /// <param name="phClientGroup"></param>
        /// <returns></returns>
        [PreserveSig]
        int SetState(
            [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)]int[] pRequestedUpdateRate,
            [Out]out	int pRevisedUpdateRate,
            [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Bool, SizeConst = 1)]bool[] pActive,
            [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)]int[] pTimeBias,
            [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)]float[] pPercentDeadband,
            [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)]int[] pLCID,
            [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)]int[] phClientGroup);

        /// <summary>
        /// 设定OPCGroup的名称
        /// </summary>
        /// <param name="szName"></param>
        /// <returns></returns>
        [PreserveSig]
        int SetName([In, MarshalAs(UnmanagedType.LPWStr)] string szName);

        /// <summary>
        ///  复制一个OPCGroup 
        /// </summary>
        /// <param name="szName"></param>
        /// <param name="riid"></param>
        /// <param name="ppUnk"></param>
        /// <returns></returns>
        [PreserveSig]
        int CloneGroup([In, MarshalAs(UnmanagedType.LPWStr)] string szName, [In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppUnk);
    }
}
